/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.base.util;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 *
 * @author joao
 */
public class ListenerContexto implements ServletContextListener, Serializable {

    
    private final static Logger logger = Logger.getLogger(ListenerContexto.class.getName());
    private static final long serialVersionUID = 1302165680737129546L;

    @Override
    public void contextInitialized(ServletContextEvent ev) {
        try {
            JPAUtil.carregarFabrica();

            //System.out.println("Fabrica JPA carregada com sucesso.");
            Logger.getLogger(ListenerContexto.class.getName()).log(Level.SEVERE, null, "");
        } catch (Exception e) {
            //System.out.println("Erro na carregamento da fabrica do JPA - " + e.getMessage());
            Logger.getLogger(ListenerContexto.class.getName()).log(Level.SEVERE, null, e);
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent ev) {
        //System.out.println("Fabrica JPA carregada com sucesso.");
        Logger.getLogger(ListenerContexto.class.getName()).log(Level.SEVERE, null, "");
    }
}